#!/usr/bin/perl -w
#
# Copyright (C) 2000-2025 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# Small test to setup a backup with $nb_files*2 to backup,
# then, we can run multiple full jobs over the directory
# and create a "large" catalog.
#
use strict;

# use bacula functions
use scripts::functions;

my $nb_files = 250000;
my $SD="storage=File";

# initialize the configuration
if ($FORCE_DEDUP eq 'yes') {
    system("scripts/copy-test-confs");
} else {
    system("scripts/copy-fifo-confs");
    $SD = "";
}

start_test();

# cleanup the previous conf
cleanup();

# Create 500,000 files in files directory
create_many_hardlinks("$cwd/files", $nb_files);

# initialize the fileset
add_to_backup_list("$cwd/files/");

# Do not use spooling
add_attribute("$conf/bacula-dir.conf", "SpoolData", "no", "Job");

# We will run the jobs as fast as possible
set_global_maximum_concurrent_jobs(10);

start_bacula();

create_bconcmds(
    "$out $tmp/log1.out",
    "label volume=TestVolume001 pool=Scratch $SD");

run_bconsole();

create_bconcmds(
    "run job=NightlySave level=full yes",
    "run job=NightlySave level=full yes",
    "run job=NightlySave level=full yes",
    "run job=NightlySave level=full yes",
    "run job=NightlySave level=full yes",
    "run job=NightlySave level=full yes",
    "wait",
    "messages");

run_bconsole();

stop_bacula();

end_test();
